<template>
    <view class="container">
        <header-bar :config="config"></header-bar>
        <view class="main"></view>
        <view class="top">
            <view class="tab">
                <view class="tab-box">
                    <view
                        class="tab-item"
                        @click="clickTab(index)"
                        v-for="(item, index) in tabs"
                        :class="{ current: tabIndex == index, 'right-current': index == 1 }"
                        :key="index">
                        <text>{{ item.title }}</text>
                        <view class="bg"></view>
                    </view>
                </view>
                <view class="tab-bg"></view>
            </view>
            <view class="scanmain" v-show="tabIndex == 0">
                <image src="@/static/img/sao.png"></image>
                <view>点击扫码下单</view>
            </view>
            <view class="searchmain" v-show="tabIndex == 1">
                <view class="input-code">
                    <input class="input input-write-off-code" placeholder="请输入商品条码上的数字" v-model="value" />
                    <text class="btn btn-white btn-search" @click="searchFn">确定</text>
                </view>
            </view>
        </view>
        <view class="massage">
            <view>条形码：2323466444</view>
            <text class="color3">找不到对应商品</text>
        </view>

        <view @click="goUrl">回</view>
    </view>
</template>

<script>
export default {
    components: {},
    data() {
        return {
            config: {
                title: "扫码下单",
                centerSlot: true,
                rightSlot: true,
            },
            valetUserId: 0,
            warehouseId: 0,
            valetUserInfo: "",
            tabIndex: 0,
            tabs: [
                {
                    type: 1,
                    title: "扫码下单",
                },
                {
                    type: 2,
                    title: "手动输入",
                },
            ],
            value: "",
        }
    },
    onLoad(e) {
        this.valetUserInfo = e.valetUserInfo
        this.valetUserId = Number(e.valetUserId)
        this.warehouseId = Number(e.warehouseId)
    },
    methods: {
        goUrl() {
            this.easyGoTo(
                "/pages/product/index-valet?valetUserId=" +
                    this.valetUserId +
                    "&valetUserInfo=" +
                    this.valetUserInfo +
                    "&warehouseId=" +
                    this.warehouseId,
            )
        },
        //tab切换
        clickTab(index) {
            if (this.tabIndex != index) {
                this.tabIndex = index
            }
        },
        searchFn() {},
    },
}
</script>

<style lang="scss">
.main {
    height: 250rpx;
    background: $app-color-main;
}
.top {
    padding: 0 24rpx;
    margin-top: -202rpx;
}

.scanmain {
    height: 216rpx;
    background: #fff;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    image {
        width: 288rpx;
        height: 130rpx;
    }
    view {
        font-size: 36rpx;
        font-weight: bold;
        color: #434c67;
        position: absolute;
    }
}
.searchmain {
    height: 216rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    padding: 0 52rpx;
    .input-code {
        display: flex;
        flex: 1;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        height: 80rpx;
        border: solid 1rpx $app-color-text-main;
        border-right: 0;
        border-radius: 100rpx;
        position: relative;
        .input-write-off-code {
            padding: 16rpx;
            display: flex;
            flex: 1;
            margin-right: 160rpx;
            color: $app-color-text-main;
            text-indent: 20rpx;
        }
        .btn-search {
            width: 150rpx;
            height: 80rpx;
            background: #222a42;
            color: $color-white;
            position: absolute;
            right: 0;
        }
    }
}
.tab {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    position: relative;
    display: flex;
    flex: 1;
    z-index: 0;

    .tab-box {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        flex: 1;
        height: 86rpx;
        perspective: 1000;
        z-index: 1;
    }

    .tab-bg {
        position: absolute;
        width: 100%;
        left: 0%;
        right: 2%;
        bottom: 0;
        z-index: 0;
        height: 82rpx;
        background: #fde9e7;
        border-radius: 24rpx 24rpx 0 0;
        border-bottom: solid 1px #dfe3ef;
    }

    .tab-item {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 76rpx;
        min-width: 45%;
        padding-bottom: 6rpx;
        &:first-child {
            border-radius: 24rpx 0 0 0;
        }

        &:last-child {
            border-radius: 0 24rpx 0 0;
        }

        text {
            color: $app-color-text-desc;
            position: relative;
            z-index: 1;
            font-size: $font-size-30;
        }
    }

    .current {
        height: 86rpx;
        overflow: hidden;
        position: relative;
        background: rgba(0, 0, 0, 0);
        width: 150%;
        text {
            color: $app-color-main;
            font-weight: 700;
            padding-top: 6rpx;
        }

        .bg {
            position: absolute;
            left: 0;
            top: 0;
            z-index: 0;
            width: 88%;
            height: 86rpx;
            /* 宽高 */
            background-color: #ffffff;
            /* 颜色 */
            // padding: 4rpx 10rpx;
            border-radius: 24rpx 18rpx 0 0;
            box-shadow: 0px 0px 7px 0px rgba(185, 192, 208, 0.4);
            /* 设置圆角 */
            transform: perspective(12rpx) rotateX(1deg);
            /* 镜头距离元素表面的位置为8px，x轴为1.1倍y轴为1.3倍，绕x轴旋转5度 */
            transform-origin: 0 0;
            /* bottom left = left bottom = 0 100% 中心点偏移量*/
        }
    }

    .right-current {
        .bg {
            margin-left: 12%;
            border-radius: 18rpx 24rpx 0 0;
            // transform: perspective(5rpx) rotateX(1deg);
            /* 镜头距离元素表面的位置为8px，x轴为1.1倍y轴为1.3倍，绕x轴旋转5度 */
            transform-origin: right 0;
        }
    }
}
.massage {
    height: 82rpx;
    background: #fdfbec;
    font-size: 28rpx;
    color: #fe6430;
    padding: 24rpx;
}
.color3 {
    color: $color-gray-3;
}
</style>
